﻿/**
*
*
*
*
*/


/*
var aryOptions=new Array(?3?);
var aryOption;aryOption = new Array("00","临时用户","1.2.3.5.4","");
aryOptions[0] = aryOption;
aryOption = new Array("99","系统管理员","1.2.3.5.4","1.2.4.5.9.10.14.12");
aryOptions[1] = aryOption;
aryOption = new Array("sa","超级系统管理员","1.2.3.5.4","1.2.3.4.5.8.9.10.11.14.12");
aryOptions[2] = aryOption;
???...

function initView(){
	for(i=0;i<?3?;i++){
		var sValue = aryOptions[i][0];
		var sText = aryOptions[i][1];
		frmAuthorize.ctrlRoleCode.options.add(new Option(sText,sValue));
	}
	for(i=0;i<?3?;i++){
		if(frmAuthorize.ctrlRoleCode[i].value==?sCtrlRoleCode?)
		frmAuthorize.ctrlRoleCode.value=?sCtrlRoleCode?;
	}
	setGrant();
}
*/

/**
* 数据库异常时用到
*/
function initView()
{
}

/**
* 显示当前控件访问角色的页面和按钮的授权信息
* 被授权的页面和按钮，其对应的页面结点和按钮结点的复选框被选中

function setGrant(){
	var index = frmAuthorize.ctrlRoleCode.selectedIndex;
	//显示当前控件访问角色的页面结点的授权信息
	var nPageCount = frmAuthorize.chkPage.length;
	for(i=0;i<nPageCount;i++)
		frmAuthorize.chkPage[i].checked = false;
	var sPageIDList = aryOptions[index][2];
  for(i=0;i<nPageCount;i++){
    var sPageID = frmAuthorize.chkPage[i].value;
    if(isContained(sPageID,sPageIDList,"."))
			frmAuthorize.chkPage[i].checked = true;
  }
	//显示当前控件访问角色的按钮结点的授权信息
	var nBtnCount = frmAuthorize.chkBtn.length;
	for(i=0;i<nBtnCount;i++)
		frmAuthorize.chkBtn[i].checked = false;
	var sBtnIDlist = aryOptions[index][3];
  for(i=0;i<nBtnCount;i++){
		var ary = frmAuthorize.chkBtn[i].value.split(".");
    var sBtnID = ary[1];
    if(isContained(sBtnID,sBtnIDlist,"."))
			frmAuthorize.chkBtn[i].checked = true;
  }
}
*/

function roleChanged(){
	setGrant();
	if(divMsg.innerHTML!=""){ //消去提示信息,同时使“授权”按钮有效
		divMsg.innerHTML = "";
		this.frmAuthorize.btnAuthorize.disabled=false;
	}
}

/**
* 若某个页面被授权（该页面结点复选框被选中），则该页面里的所有按钮都默认被授权（该页面结点下的所有按钮结点的复选框都默认被选中）；
*	若某个页面被取消授权（该页面结点复选框被取消选中），则该页面里的所有按钮都被取消授权（该页面结点下的所有按钮结点的复选框都被取消选中）；

function pageChkboxClick(obj){
  var sPageID = obj.value;
	var nPageCount = frmAuthorize.chkPage.length;
	var nBtnCount = frmAuthorize.chkBtn.length;
	if(obj.checked){
		//范畴为0时,同时设置可能还出现在其它位置的同一个页面结点
		for(i=0;i<nPageCount;i++){
			if(frmAuthorize.chkPage[i].value==sPageID)
				frmAuthorize.chkPage[i].checked=true;
		}
    //设置该页面结点下的按钮结点  范畴为0时???????
		for(i=0;i<nBtnCount;i++){
			var sBtnChkboxValue = frmAuthorize.chkBtn[i].value;
			var ary = sBtnChkboxValue.split(".");
      if(ary[0]==sPageID)
      	frmAuthorize.chkBtn[i].checked = true;
		}
	}
	else{
		for(i=0;i<nPageCount;i++){
			if(frmAuthorize.chkPage[i].value==sPageID)
				frmAuthorize.chkPage[i].checked=false;
		}
		for(i=0;i<nBtnCount;i++){
			var sBtnChkboxValue = frmAuthorize.chkBtn[i].value;
			var ary = sBtnChkboxValue.split(".");
      if(ary[0]==sPageID)
      	frmAuthorize.chkBtn[i].checked = false;
		}
	}
	if(divMsg.innerHTML!=""){ //消去提示信息,同时使“授权”按钮有效
		divMsg.innerHTML = "";
		this.frmAuthorize.btnAuthorize.disabled=false;
	}
}
*/

/**
* 选中或取消选中按钮结点的复选框
*/
function btnChkboxClick(obj){
	var sPageBtnID = obj.value;
  var ary = sPageBtnID.split(".");
	var sPageID = ary[0];
	var nPageCount = frmAuthorize.chkPage.length;
	var nBtnCount = frmAuthorize.chkBtn.length;
	if(obj.checked){
		//选中某个按钮结点后，其所属的页面结点也应被选中
		for(i=0;i<nPageCount;i++){
			if(frmAuthorize.chkPage[i].value==sPageID && !frmAuthorize.chkPage[i].checked)
				frmAuthorize.chkPage[i].checked=true;
		}
		//范畴为0时,同时设置可能还出现在其它位置的同一个按钮结点
		for(i=0;i<nBtnCount;i++){
			if(frmAuthorize.chkBtn[i].value==sPageBtnID)
				frmAuthorize.chkBtn[i].checked=true;
		}
	}
	else{
		for(i=0;i<nBtnCount;i++){
			if(frmAuthorize.chkBtn[i].value==sPageBtnID)
				frmAuthorize.chkBtn[i].checked=false;
		}
	}
	if(divMsg.innerHTML!=""){
		divMsg.innerHTML = "";
		this.frmAuthorize.btnAuthorize.disabled=false;
	}
}

/**
* 规整好页面和按钮的授权信息后再提交

function authorize(){
  frmAuthorize.btnAuthorize.disabled = true;
	//将页面结点的授权信息写入对应的隐藏域
	var nPageCount = frmAuthorize.chkPage.length;
	var sPageIDList = "";
  for(i=0;i<nPageCount;i++){
    if(frmAuthorize.chkPage[i].checked){
      var sPageID = frmAuthorize.chkPage[i].value;
			if(!isContained(sPageID,sPageIDList,"^")) //剔除重复数据
      	sPageIDList = sPageIDList + sPageID + "^";
    }
  }
  frmAuthorize.hidPageIDList.value = sPageIDList;
  //将按钮结点的授权信息写入对应的隐藏域
	var nBtnCount = frmAuthorize.chkBtn.length;
	var sBtnIDList = "";
  for(i=0;i<nBtnCount;i++){
    if(frmAuthorize.chkBtn[i].checked){
      var sPageBtnID = frmAuthorize.chkBtn[i].value;
			var ary = sPageBtnID.split(".");
			var sBtnID = ary[1];
      if(!isContained(sBtnID,sBtnIDList,"^"))
      	sBtnIDList = sBtnIDList + sBtnID + "^";
    }
  }
  frmAuthorize.hidBtnIDList.value = sBtnIDList;
  //提交授权信息
  frmAuthorize.submit();
}
*/